//
//  QSShareViewCell.swift
//  TestSwift
//
//  Created by Song on 2018/7/3.
//  Copyright © 2018年 Song. All rights reserved.
//

import UIKit

class QSShareViewCell: UICollectionViewCell {
    // 子控件
    var imgView: UIImageView?
    var titleLab: UILabel?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setupSubViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /// 设置界面
    private func setupSubViews() {
        // imgView
        imgView = UIImageView.init()
        self.contentView.addSubview(imgView!)
        imgView!.snp.makeConstraints { (make) in
            make.top.equalTo(10.0)
            make.centerX.equalTo(self.contentView)
            make.width.height.equalTo(60.0)
        }
        
        // titleLab
        titleLab = UILabel.init()
        self.contentView.addSubview(titleLab!)
        titleLab!.snp.makeConstraints { (make) in
            make.left.equalTo(5.0)
            make.right.equalTo(-5.0)
            make.top.equalTo(imgView!.snp.bottom).offset(10.0)
        }
        
        titleLab!.font = UIFont.systemFont(ofSize: 12.0)
        titleLab!.textColor = UIColor.black
        titleLab!.textAlignment = NSTextAlignment.center
    }
    
    /// 设置cell
    ///
    /// - Parameter platform: 平台类型
    func setSharePlatform(_ platform : UMSocialPlatformType) {
        var imgName = ""
        var title = ""
        
        switch platform {
        case .sina:
            imgName = kSinaShareBtnImageName
            title = kSinaShareBtnTitle
            
        case .QQ:
            imgName = kQQShareBtnImageName
            title = kQQShareBtnTitle
            
        case .qzone:
            imgName = kQQzoneShareBtnImageName
            title = kQQzoneShareBtnTitle
            
        case .wechatSession:
            imgName = kWechatSessionShareBtnImageName
            title = kWechatSessionShareBtnTitle
            
        case .wechatTimeLine:
            imgName = kWechatTimelineShareBtnImageName
            title = kWechatTimelineShareBtnTitle
            
        case .dingDing:
            imgName = kDingDingImageName
            title = kDingDingShareBtnTitle
        default:
            imgName = ""
            title = ""
        }
        
        self.imgView?.image = UIImage.init(named: imgName)
        self.titleLab?.text = title
    }
}
